home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6669 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: odin.visigenic.com!news
  2. From: Tim O'Neil <toneil@visigenic.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Function wanted to evaluate string
  5. Date: Fri, 16 Feb 1996 13:34:44 +0000
  6. Organization: Visigenic Software, Inc.
  7. Message-ID: <312487F4.6086@visigenic.com>
  8. References: <4g20eo$623@coranto.ucs.mun.ca>
  9. NNTP-Posting-Host: vsi48.visigenic.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b5 (WinNT; I)
  14.  
  15. Chris Deacon wrote:
  16. > I want a function which will evaluate a string of numbers and
  17. > arithmetic operators. That is, whwn I call 
  18. > eval_func(2*5)
  19.  
  20. >  a value of 10 will be returned.
  21.  
  22. > Ideally, I'd like the code to be able to handle several operators
  23. > in the string, so that 
  24. > eval_func((3*5.7)/(2-.77)+4.5) 
  25. > will be evaluated just as easily. 
  26. > All suggestions gratefully appreciated..
  27.  
  28. Look for string math libraries in your delopment enviroment. You might
  29. scan string.h for function prototypes. I would avoid string math if you
  30. can possibly do so however. Better to do the math with appropriate types
  31. and then map results to strings. (imho, anyway)
  32.